<?php
/*
 * Created on 2011-5-13
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 
// require_once('../nusoap/lib/nusoap.php');
 require_once('json.php');
 require_once('database.php');
 
 function LovePet($json='')
 {
 	$arr = json_str_to_array($json);
// 	print_r($arr);
 	
	$maindo = isset($arr['maindo'])?intval($arr['maindo']):0;
	$subdo = isset($arr['subdo'])?intval($arr['subdo']):0;

//	return $maindo."&".$subdo;
	
	switch ($maindo)
	{
		case 1:
		{
			return User($arr);
		}
		break;
		case 2:
		{
			return Pet($arr);
		}
		break;
		case 3:
		{
			return Rank($arr);
		}
		break;
	}
	$err = 'LovePet Err maindo='.$maindo;
	return $err;
 }
 
 function Pet($param)
 {
	$arr = (array)$param;
	$subdo = $arr['subdo'];
	switch ($subdo)
	{
		case 1:
		break;
	}
	$ret = "Pet Err";
	return $ret;
 }
 
 function User($param)
 {
	$arr = (array)$param;
	$subdo = $arr['subdo'];
	switch ($subdo)
	{
		case 1:
			//login
			return login($arr);
		break;
		case 2:
			//reg
			return reg($arr);
		break;
		case 3:
			//add lover
			return AddLover($arr);
		break;
		case 4:
			//del lover
			return DelLover($arr);
		break;
		case 5:
			//allow to be lovers
			return ToBeLover($arr);
		break;
		case 6:
		//find lover
			return FindLover($arr);
		break;
	}
	$ret = "User Err";
	return $ret;
 }
 
 function Rank($param)
 {
	$arr = (array)$param;
	$subdo = $arr['subdo'];
	switch ($subdo)
	{
		case 1:
		break;
	}
	$ret = "Rank Err";
	return $ret;
 }
  
// $server = new soap_server();
// $server->configureWSDL('LoverPetSDK','urn:LoverPetSDK');
// $server->wsdl->schemaTargetNamespace='urn:LoverPetSDK';
// $server->register("LovePet",
// 	array('json'=>'xsd:string'),
// 	array('return'=>'xsd:string'),
// 	'urn:LoverPetSDK',
// 	'urn:LoverPetSDK#LovePet');
// 	
// $HTTP_RAW_POST_DATA=isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:'';
// $server->service($HTTP_RAW_POST_DATA);
 	
// echo '<br/>End Interface<br/>';
?>
